package com.dashang.rebatecenter.controller;

import com.dashang.rebatecenter.bean.MfKucn;
import com.dashang.rebatecenter.bean.ResponseBean;
import com.dashang.rebatecenter.bean.ResponseList;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 消息处理基类
 *
 * @author 段旭东
 * @since 2019/8/6
 */
@RestController
@Slf4j
public class BaseController {

    @GetMapping("/data")
    public ResponseList RequestParam(@RequestParam("tableName") String tableName, @RequestParam("object") String object) {
        log.info("==================={}  {}", tableName, object);
        ResponseList<MfKucn> bean = new ResponseList();

        List<String> hhs = Arrays.asList(object.split(","));
        List<MfKucn> list = new ArrayList<>();
        for (String hh : hhs) {
            MfKucn k = new MfKucn();
            k.setHh(hh);
            k.setKucn("1111");
            list.add(k);
        }
        bean.setDatas(list);
        return bean;
    }

    @GetMapping("/data2")
    public ResponseBean getSpInfo1(@RequestParam("tableName") String tableName, @RequestParam("object") String object) {
        log.info("==================={}  {}", tableName, object);
        ResponseBean<MfKucn> bean = new ResponseBean();
        MfKucn k = new MfKucn();
        k.setHh(object);
        k.setKucn("2222");
        bean.setData(k);
        return bean;
    }


}
